#ifndef INDEX_BUILDER_H
#define INDEX_BUILDER_H

#include <string>
#include "doc_manager.h"
#include "index_manager.h"

class IndexBuilder {
public:
    IndexBuilder(std::string indexDB, std::string docDB);
    ~IndexBuilder();

    int LoadDB();
    int AddDoc(std::string &title, std::string &body);
private:
    int ParseDoc(int docID, std::string &body);
    int UpdatePosting(PostingList &postingList);
    int NgramNext(const std::string &body, std::string &token, int &pos);

private:
    DocManager docMgr_;
    IndexManager indexMgr_;
    InvertedIndex index_;
    std::string indexDBPath_;
    std::string docDBPath_;
};

#endif
